package EA.testproblems;
import java.util.Hashtable;

/** This class is a helper class to make selection of problems more easy so
    you can make the problem selection a part of the settingsfile for the
    BatchJobScheduler.
*/   

public class NumericalProblemSelector
{

  /** Return a problem from the package based on the name of the problem. 
      This method takes a settings hashtable and looks for the key 
      "problemname". 
      <b>Note:</b> The match is case-insensitive so SchafferF6 is equal
      to scHaFFErf6<br>
      If the problem wasn't found this method will print and error and
      call System.exit(0)
  */
  public static NumericalProblem selectProblem(Hashtable settings)
    {
      return selectProblem((String)settings.get("problemname"));
    }
  /** Return a problem from the package based on the name of the problem. 
      <b>Note:</b> The match is case-insensitive so SchafferF6 is equal
      to scHaFFErf6<br>
      If the problem wasn't found this method will print and error and
      call System.exit(0)
  */
  public static NumericalProblem selectProblem(String problemname)
    {
      String orgname = problemname.trim();

      problemname = (problemname.toLowerCase()).trim();

      if (problemname.equals("dejongf1"))
	return new DeJongF1();
      if (problemname.equals("dejongf2"))
	return new DeJongF2();
      if (problemname.equals("dejongf3"))
	return new DeJongF3();
      if (problemname.equals("dejongf4"))
	return new DeJongF4();
      if (problemname.equals("colville"))
	return new Colville();
      if (problemname.equals("easom"))
	return new Easom();
      
      if (problemname.equals("goldsteinprice"))
	return new GoldsteinPrice();

      if (problemname.equals("goldbergf1"))
	return new GoldbergF1();
      if (problemname.equals("goldbergf2"))
	return new GoldbergF2();

      if (problemname.equals("braninrcos"))
	return new BraninRCOS();
      
      if (problemname.equals("bohachevskyf1"))
	return new BohachevskyF1();
      if (problemname.equals("bohachevskyf2"))
	return new BohachevskyF2();
      if (problemname.equals("bohachevskyf3"))
	return new BohachevskyF3();

      if (problemname.equals("ursemmultimodal1"))
	return new UrsemMultimodal1();
      if (problemname.equals("ursemmultimodal2"))
	return new UrsemMultimodal2();
      if (problemname.equals("ursemmultimodal3"))
	return new UrsemMultimodal3();
      if (problemname.equals("ursemmultimodal4"))
	return new UrsemMultimodal4();
      if (problemname.equals("ursemmultimodal5"))
	return new UrsemMultimodal5();
      if (problemname.equals("ursemmultimodal6"))
	return new UrsemMultimodal6();
      if (problemname.equals("ursemmultimodal7"))
	return new UrsemMultimodal7();

      if (problemname.equals("ursemmultimodal8"))
	return new UrsemMultimodal8();
      if (problemname.equals("ursemmultimodal8_5d"))
	return new UrsemMultimodal8_5D();
      if (problemname.equals("ursemmultimodal8_10d"))
	return new UrsemMultimodal8_10D();
      if (problemname.equals("ursemmultimodal8_20d"))
	return new UrsemMultimodal8_20D();
      if (problemname.equals("ursemmultimodal8_30d"))
	return new UrsemMultimodal8_30D();
      if (problemname.equals("ursemmultimodal8_50d"))
	return new UrsemMultimodal8_50D();
      if (problemname.equals("ursemmultimodal8_100d"))
	return new UrsemMultimodal8_100D();
      
      if (problemname.equals("ursemmultimodal9"))
	return new UrsemMultimodal9();
      if (problemname.equals("ursemmultimodal9_5d"))
	return new UrsemMultimodal9_5D();
      if (problemname.equals("ursemmultimodal9_10d"))
	return new UrsemMultimodal9_10D();
      if (problemname.equals("ursemmultimodal9_20d"))
	return new UrsemMultimodal9_20D();
      if (problemname.equals("ursemmultimodal9_30d"))
	return new UrsemMultimodal9_30D();
      if (problemname.equals("ursemmultimodal9_50d"))
	return new UrsemMultimodal9_50D();
      if (problemname.equals("ursemmultimodal9_100d"))
	return new UrsemMultimodal9_100D();
      
      if (problemname.equals("ursemmultimodal10_1"))
	return new UrsemMultimodal10_1();
      if (problemname.equals("ursemmultimodal10_2"))
	return new UrsemMultimodal10_2();
      if (problemname.equals("ursemmultimodal10_5"))
	return new UrsemMultimodal10_5();
      if (problemname.equals("ursemmultimodal10_10"))
	return new UrsemMultimodal10_10();
      if (problemname.equals("ursemmultimodal10_20"))
	return new UrsemMultimodal10_20();
      if (problemname.equals("ursemmultimodal10_50"))
	return new UrsemMultimodal10_50();
      if (problemname.equals("ursemmultimodal10_100"))
	return new UrsemMultimodal10_100();
      if (problemname.equals("ursemmultimodal10_1x2"))
	return new UrsemMultimodal10_1x2();
      if (problemname.equals("ursemmultimodal10_1x10"))
	return new UrsemMultimodal10_1x10();

      if (problemname.equals("ursemmultimodal11"))
	return new UrsemMultimodal11();

      if (problemname.equals("dynamicdejongtcg1"))
	return new DynamicDeJongTCG1();
      if (problemname.equals("dynamicdejongtcg2"))
	return new DynamicDeJongTCG2();
      if (problemname.equals("dynamicdejongtcg3"))
	return new DynamicDeJongTCG3();
      
      if (problemname.equals("schafferf6"))
	return new SchafferF6();
      if (problemname.equals("schaffertiltedf6"))
	return new SchafferTiltedF6();
      
      if (problemname.equals("schafferf7"))
	return new SchafferF7();
      if (problemname.equals("schaffertiltedf7"))
	return new SchafferTiltedF7();
      
      if (problemname.equals("sixhumpcamelback"))
	return new SixHumpCamelBack();
      
      if (problemname.equals("rastriginf1"))
	return new RastriginF1();
      if (problemname.equals("rastriginf1_3d"))
	return new RastriginF1_3D();
      if (problemname.equals("rastriginf1_5d"))
	return new RastriginF1_5D();
      if (problemname.equals("rastriginf1_10d"))
	return new RastriginF1_10D();
      if (problemname.equals("rastriginf1_20d"))
	return new RastriginF1_20D();
      if (problemname.equals("rastriginf1_30d"))
	return new RastriginF1_30D();
      if (problemname.equals("rastriginf1_50d"))
	return new RastriginF1_50D();
      if (problemname.equals("rastriginf1_100d"))
	return new RastriginF1_100D();
      if (problemname.equals("rastriginf1_1000d"))
	return new RastriginF1_1000D();
      
      if (problemname.equals("ackleyf1"))
	return new AckleyF1();
      if (problemname.equals("ackleyf1_3d"))
	return new AckleyF1_3D();
      if (problemname.equals("ackleyf1_5d"))
	return new AckleyF1_5D();
      if (problemname.equals("ackleyf1_10d"))
	return new AckleyF1_10D();
      if (problemname.equals("ackleyf1_20d"))
	return new AckleyF1_20D();
      if (problemname.equals("ackleyf1_30d"))
	return new AckleyF1_30D();
      if (problemname.equals("ackleyf1_50d"))
	return new AckleyF1_50D();
      if (problemname.equals("ackleyf1_100d"))
	return new AckleyF1_100D();
      if (problemname.equals("ackleyf1_1000d"))
	return new AckleyF1_1000D();
      
      if (problemname.equals("griewank"))
	return new Griewank();

      if (problemname.equals("griewankf1"))
	return new GriewankF1();
      if (problemname.equals("griewankf1_3d"))
	return new GriewankF1_3D();
      if (problemname.equals("griewankf1_5d"))
	return new GriewankF1_5D();
      if (problemname.equals("griewankf1_10d"))
	return new GriewankF1_10D();
      if (problemname.equals("griewankf1_20d"))
	return new GriewankF1_20D();
      if (problemname.equals("griewankf1_30d"))
	return new GriewankF1_30D();
      if (problemname.equals("griewankf1_50d"))
	return new GriewankF1_50D();
      if (problemname.equals("griewankf1_100d"))
	return new GriewankF1_100D();
      if (problemname.equals("griewankf1_1000d"))
	return new GriewankF1_1000D();

      if (problemname.equals("rosenbrockf1"))
	return new RosenbrockF1();
      if (problemname.equals("rosenbrockf1_3d"))
	return new RosenbrockF1_3D();
      if (problemname.equals("rosenbrockf1_5d"))
	return new RosenbrockF1_5D();
      if (problemname.equals("rosenbrockf1_10d"))
	return new RosenbrockF1_10D();
      if (problemname.equals("rosenbrockf1_20d"))
	return new RosenbrockF1_20D();
      if (problemname.equals("rosenbrockf1_30d"))
	return new RosenbrockF1_30D();
      if (problemname.equals("rosenbrockf1_50d"))
	return new RosenbrockF1_50D();
      if (problemname.equals("rosenbrockf1_100d"))
	return new RosenbrockF1_100D();
      if (problemname.equals("rosenbrockf1_1000d"))
	return new RosenbrockF1_1000D();

      if (problemname.equals("realmathematicalproblem1"))
	return new RealMathematicalProblem1();
      
      if (problemname.equals("realmathematicalproblem2"))
	return new RealMathematicalProblem2();
      
      if (problemname.equals("krinkf1"))
	return new KrinkF1();
      
      if (problemname.equals("michalewicz"))
	return new Michalewicz();
      


      System.out.println("The problem named \""+orgname+"\" could not be found. (Check spelling or update class NumericalProblemSelector!)");
      System.exit(0);
      
      return null;
    }

}

	  

